linux_aria

My file bash, and configurate for linux


Project maintained by ariafatah0711 Hosted on GitHub Pages — Theme by mattgraham

database

ubuntu

redhat

sql command

databases

CREATE DATABASE db_kucing;
DROP DATABASE db_test;

SHOW DATABASES;
USE db_kucing;
status

tables

CREATE TABLE data_kucing (
  Id int,
  Nama varchar(300),
  Jenis char(300),
  Umur int
);


SHOW TABLES;
DESC table_kucing;
DESCRIBE data_kucing;

DROP TABLE data_test;
TRUNCATE TABLE data_test;

ALTER TABLE data_kucing
ADD power varchar(100) NOT NULL,
DROP COLUMN power;

ALTER TABLE data_kucing
MODIFY COLUMN umur varchar(2);

INSERT

INSERT INTO data_kucing VALUES (1, “popy”, “jantan”, 15);
INSERT INTO data_kucing (id) values (1)

select

SELECT * FROM data_kucing;

SELECT id, name FROM data_kucing;
SELECT id, nama FROM data_kucing WHERE “popy”;
SELECT id, nama FROM data_kucing WHERE umur > 15 AND jenis=”betina”;
SELECT id, nama FROM data_kucing WHERE umur > 15 ORDER BY umur;
SELECT id, nama FROM data_kucing WHERE umur > 15 ORDER BY nama ASC;
SELECT id, nama FROM data_kucing LIMIT 0,3;

delete

DELETE FROM data_kucing WHERE umur=15;
DELETE FROM data_kucing WHERE id=1;
DELETE FROM data_kucing;

update

UPDATE data_kucing SET nama=”aria”, warna=”putih” WHERE id=1;

primary key and foreign key

CREATE TABLE owners (
  Id int NOT NULL,
  Age int,
  PRIMARY KEY (id)
)

CREATE TABLE data_kucing (
  Id_kucing int NOT NULL,
  id_owner int NOT NULL,
  Nama varchar(300) UNIQE,
  PRIMARY KEY (id_kucing),
  FOREIGN KEY (id_owner) REFERENCES owners(id)
)

more type data

CREATE TABLE owners (
  Id int NOT NULL,
  Nama varchar(300),
  Age int,
  UNIQUE.  (Id),
  CHECK(id > 100)
  CONSTRAINT UC_Person UNIQUE (id, nama);
)

test

AND OR NOT

NOT NULL - Ensures that a column cannot have a NULL value
UNIQUE - Ensures that all values in a column are different
PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifies each row in a table
FOREIGN KEY - Prevents actions that would destroy links between tables
CHECK - Ensures that the values in a column satisfies a specific condition
DEFAULT - Sets a default value for a column if no value is specified
CREATE INDEX - Used to create and retrieve data from the database very quickly